﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DTO;
using System.Data;
using System.Data.OleDb;

namespace DAO
{
    public class FriendListDao : ConectionClass
    {
        public static void AddFriend(FriendList friendList)
        {
            OleDbConnection conn = ConectionClass.CreateConnection();
            string strComm = "Insert Into FriendList([Username], [Friend], [Status]) Values(?, ?, ?);";
            OleDbCommand comm = new OleDbCommand(strComm, conn);
            comm.Parameters.Add("@Username", OleDbType.VarChar).Value = friendList.Username;
            comm.Parameters.Add("@Friend", OleDbType.VarChar).Value = friendList.Friend;
            comm.Parameters.Add("@Status", OleDbType.VarChar).Value = friendList.Status;

            try
            {
                comm.ExecuteNonQuery();
                conn.Close();
            }
            catch (Exception ex)
            {
                conn.Close();
                throw ex;
            }
        }
    }
}
